#include "formskaoqin.h"
#include "ui_formskaoqin.h"
#include<QMessageBox>
#include<QSqlDatabase>
#include<QSqlQueryModel>

#include"student.h"

FormSkaoqin::FormSkaoqin(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FormSkaoqin)
{
    ui->setupUi(this);
}

FormSkaoqin::~FormSkaoqin()
{
    delete ui;
}

void FormSkaoqin::showFormSkaoqin()
{
    emit signalformSkaoqin();
    this->show();
}

void FormSkaoqin::on_pb_checkin_ok_clicked()
{
    ui->lineEdit_checkin_classid->setPlaceholderText(tr("classid"));
    QSqlQueryModel *model1 = new QSqlQueryModel(ui->tableView_checkin);
//        if(ui->lineEdit_checkin_classid->text() == "all")
//        {
//             model1->setQuery(QString("select * from CheckinInfoTable;"));
//         }else{
            model1->setQuery(QString("select * from CheckinInfoTable where Classid = '%1';").arg(ui->lineEdit_checkin_classid->text()));
//        }
    //列名
    model1->setHeaderData(0, Qt::Horizontal, tr("XID"));
    model1->setHeaderData(1, Qt::Horizontal, tr("ScienceID"));
    model1->setHeaderData(2, Qt::Horizontal, tr("teacherId"));
    model1->setHeaderData(3, Qt::Horizontal, tr("Classid"));
    model1->setHeaderData(4, Qt::Horizontal, tr("RoomID"));
    model1->setHeaderData(6, Qt::Horizontal, tr("xuehao"));
    model1->setHeaderData(5, Qt::Horizontal, tr("CheckinTime"));

    ui->tableView_checkin->setModel(model1);//数据放置进去
    ui->tableView_checkin->verticalHeader()->hide();//不显示序号
}

void FormSkaoqin::showSW()
{
    Student *tw = new Student;
    tw->show();
    tw->selectBoxSlot(str);
}
void FormSkaoqin::on_pushButton_cancle_clicked()
{
    this->close();
    this->showSW();

}
